/**
 * 
 */
package org.vsg.common.jobscheduler.provider;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.quartz.utils.ConnectionProvider;

/**
 * @author Bill vison Defined the spring provider
 *
 */
public class SpringframeworkConnectionProvider implements ConnectionProvider {
	
	private DataSource dataSource;

	public DataSource getDataSource() {
		return dataSource;
	}

	public void setDataSource(DataSource dataSource) throws SQLException {
		if (dataSource == null) {
			throw new SQLException("javax.sql.DataSource is not defined , instant is " + dataSource);
		}
		
		this.dataSource = dataSource;
	}

	/* (non-Javadoc)
	 * @see org.quartz.utils.ConnectionProvider#getConnection()
	 */
	@Override
	public Connection getConnection() throws SQLException {
		// TODO Auto-generated method stub
		return dataSource.getConnection();
	}

	/* (non-Javadoc)
	 * @see org.quartz.utils.ConnectionProvider#shutdown()
	 */
	@Override
	public void shutdown() throws SQLException {
		// TODO Auto-generated method stub

	}

}
